home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / comm / vt100r29.5 < prev    next >
Internet Message Format  |  1989-10-20  |  48KB

  1. Path: xanth!mcnc!rutgers!ucsd!tut.cis.ohio-state.edu!mailrus!ames!sun-barr!newstop!sun!swap!page
  2. From: page%swap@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i182:  vt100 - terminal emulator v2.9, Part05/09
  5. Message-ID: <126578@sun.Eng.Sun.COM>
  6. Date: 20 Oct 89 06:09:58 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 1779
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: acs@pccuts.pcc.amdahl.com (Tony Sumrall)
  12. Posting-number: Volume 89, Issue 182
  13. Archive-name: comm/vt100r29.5
  14.  
  15. # This is a shell archive.
  16. # Remove anything above and including the cut line.
  17. # Then run the rest of the file through 'sh'.
  18. # Unpacked files will be owned by you and have default permissions.
  19. #----cut here-----cut here-----cut here-----cut here----#
  20. #!/bin/sh
  21. # shar: SHell ARchive
  22. # Run the following text through 'sh' to create:
  23. #    Zmodem/SerIO.c
  24. #    Zmodem/term.c
  25. #    expand.c
  26. #    init.c
  27. # This is archive 5 of a 9-part kit.
  28. # This archive created: Thu Oct 19 22:30:30 1989
  29. if `test ! -d Zmodem`
  30. then
  31.   mkdir Zmodem
  32.   echo "mkdir Zmodem"
  33. fi
  34. echo "extracting Zmodem/SerIO.c"
  35. sed 's/^X//' << \SHAR_EOF > Zmodem/SerIO.c
  36. X
  37. X#define ERROR (-1)     /* don't change these 2 because they have to */
  38. X#define TIMEOUT (-2)   /* be the same as the #defines in sz.c and rz.c */
  39. X
  40. X#define SERBUFSIZE 1024L
  41. X
  42. X/*
  43. X *   Serial IO functions
  44. X *
  45. X *    based on routines by A.Livshits & J.M.Forgeas
  46. X *
  47. X *   Extensively modified for Amiga zmodem by Frank Harper
  48. X */
  49. X
  50. X#include <stdio.h>
  51. X#include <ctype.h>
  52. X#include <exec/types.h>
  53. X#include <exec/nodes.h>
  54. X#include <exec/memory.h>
  55. X#include <exec/io.h>
  56. X#include <exec/errors.h>
  57. X#include <exec/ports.h>
  58. X#include <devices/timer.h>
  59. X#include <devices/serial.h>
  60. X#include <libraries/dos.h>
  61. X#include "intuition/intuition.h"
  62. X
  63. Xextern int Lleft;             /* number of chars in input buffer */
  64. Xextern UBYTE  SerOpen;             /* True if Serial port is open */
  65. Xstatic UBYTE TimeOpen;
  66. Xextern struct IOExtSer *InSer, *OutSer;
  67. Xextern struct MsgPort  *InSerPort, *OutSerPort;
  68. X
  69. Xextern ULONG  InSerSigMask, OutSerSigMask; /* Masks for Wait & WaitIO */
  70. Xextern ULONG  IOTimeSigMask;
  71. X
  72. Xextern struct timerequest *IOTime;
  73. Xextern struct MsgPort *TimerPort;
  74. Xextern struct Window *Win;
  75. Xstruct MsgPort *CreatePort();
  76. Xvoid *CreateExtIO(),*AllocMem();
  77. X
  78. Xstatic UBYTE  RecSerBuf[SERBUFSIZE];    /* Serial input buffer */
  79. Xstatic UBYTE Previous=FALSE;        /* True if asynchronous serial
  80. X                       write is pending */
  81. X
  82. X
  83. Xextern int Enable_Abort = 0;        /* No ^C allowed (Manx) */
  84. X
  85. X /*
  86. X  * Init. serial port
  87. X  *
  88. X  * bps: bits per second (or Baud rate) between 110 and 29,200
  89. X  *    if this parameter is -1 then the device is opened with
  90. X  *    no changes in bps,len, or stop.
  91. X  *
  92. X  * len: lenght of each word sent and received (7 or 8)
  93. X  * stop: number of stop bits 1 or 2
  94. X  * flags: used to set other parameters
  95. X  *
  96. X  * returns pointer to IOExtSer structure, so caller can determine what
  97. X  * the serial parameters in use actually are. In case of failure
  98. X  * return NULL.
  99. X  */
  100. X
  101. Xstruct IOExtSer *SetSer(bps,len,stop,flags)
  102. XULONG bps,len,stop,flags;
  103. X{
  104. X
  105. X   if( bps!=-1 && (bps<110 || bps>29200 || len<7 || len>8 ||
  106. X            stop<1 || stop>2)) return NULL;
  107. X
  108. X   InSer = (struct IOExtSer *) AllocMem((long)sizeof(*InSer),MEMF_PUBLIC|MEMF_CLEAR);
  109. X   if(InSer==NULL) return NULL;
  110. X
  111. X   OutSer = (struct IOExtSer *) AllocMem((long)sizeof(*OutSer),MEMF_PUBLIC|MEMF_CLEAR);
  112. X   if( OutSer==NULL) return NULL;
  113. X
  114. X   InSerPort = InSer->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  115. X   if(InSerPort==NULL) return NULL;
  116. X
  117. X   InSerSigMask = 1 << (InSerPort->mp_SigBit);
  118. X   InSer->io_SerFlags = SERF_SHARED&flags;
  119. X
  120. X   if(OpenDevice(SERIALNAME,NULL,InSer,NULL)) {
  121. X       fprintf(stderr,"Error opening serial device\n");
  122. X       return NULL;
  123. X   }
  124. X   if( bps!=-1 ) {
  125. X     InSer->io_SerFlags = flags;
  126. X     InSer->io_Baud    = bps;
  127. X     InSer->io_ReadLen    = InSer->io_WriteLen = len;
  128. X     InSer->io_StopBits = stop;
  129. X     InSer->io_CtlChar    = 0x11130000L;
  130. X     InSer->io_RBufLen    = SERBUFSIZE;
  131. X     InSer->io_BrkTime    = 250000L;
  132. X     InSer->IOSer.io_Command = SDCMD_SETPARAMS;
  133. X     if( DoIO(InSer)!=0 ) {
  134. X     fprintf(stderr,"Error setting serial port parameters\n");
  135. X     return NULL;
  136. X     }
  137. X   }
  138. X   CopyMem(InSer,OutSer,sizeof(struct IOExtSer));
  139. X   OutSerPort = OutSer->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  140. X   if(OutSerPort==NULL) return NULL;
  141. X   OutSerSigMask = 1 << (OutSerPort->mp_SigBit);
  142. X   SerOpen=1;
  143. X   return InSer;
  144. X}
  145. X
  146. X /*
  147. X  * Close serial port
  148. X  */
  149. X
  150. Xvoid  CloseSer()
  151. X{
  152. X    if(Previous) {
  153. X    Wait(OutSerSigMask);
  154. X    GetMsg(OutSerPort);
  155. X    }
  156. X    if(SerOpen) {
  157. X    CloseDevice(InSer);
  158. X    SerOpen=0;
  159. X    }
  160. X    if(OutSerPort) {
  161. X    DeletePort(OutSerPort);
  162. X    OutSerPort=NULL;
  163. X    }
  164. X    if(InSerPort)  {
  165. X    DeletePort(InSerPort);
  166. X    InSerPort=NULL;
  167. X    }
  168. X    if(OutSer) {
  169. X    FreeMem(OutSer,(long)sizeof(*OutSer));
  170. X    OutSer=NULL;
  171. X    }
  172. X    if(InSer) {
  173. X    FreeMem(InSer,(long)sizeof(*InSer));
  174. X    InSer=NULL;
  175. X    }
  176. X}
  177. X
  178. X /*
  179. X  * Write asynchronously the len characters (up to SERBUFSIZE) pointed
  180. X  * at by c.
  181. X  */
  182. X
  183. Xint LWriteSer(c,len)
  184. XUBYTE  *c;
  185. Xint len;
  186. X{
  187. X
  188. X   ULONG  IntuiMask,mask;
  189. X   static UBYTE buf[SERBUFSIZE];
  190. X
  191. X    if (len==0) return (0);
  192. X    if (len > SERBUFSIZE || SerOpen==0) return ERROR;
  193. X    if (Previous) {
  194. X    IntuiMask = 1 << (Win->UserPort->mp_SigBit);
  195. X    mask = Wait(OutSerSigMask | IntuiMask);
  196. X    if ((mask & IntuiMask) && CheckQuit()) {
  197. X        KillIO( (struct IOStdReq *)OutSer,mask);
  198. X        Previous=FALSE;
  199. X        bibi(1);
  200. X    }
  201. X    GetMsg(OutSerPort);
  202. X    }
  203. X    Previous = TRUE;
  204. X    CopyMem(c,buf,len);
  205. X    OutSer->IOSer.io_Data = (APTR)buf;
  206. X    OutSer->IOSer.io_Length = (ULONG)len;
  207. X    OutSer->IOSer.io_Command = CMD_WRITE;
  208. X    SendIO(OutSer);
  209. X    return (0);
  210. X}
  211. X
  212. X /*
  213. X  * Send an asynchronous read request for n characters
  214. X  * put result in buf
  215. X  */
  216. X
  217. XSendSer(n,buf)
  218. Xint n;
  219. Xchar *buf;
  220. X{
  221. X    if( SerOpen==0 ) {
  222. X    fprintf(stderr,"Read attempt on closed Serial Port\n");
  223. X    return ERROR;
  224. X    }
  225. X    InSer->IOSer.io_Data = (APTR)buf;
  226. X    InSer->IOSer.io_Length = n;
  227. X    InSer->IOSer.io_Command = CMD_READ;
  228. X    SendIO(InSer);
  229. X    return (0);
  230. X}
  231. X
  232. X /*
  233. X  * Purge any characters waiting in serial port queue
  234. X  *
  235. X  */
  236. X
  237. XPurgeSer()
  238. X{
  239. X    if( SerOpen!=0 ) {
  240. X     InSer->IOSer.io_Command = CMD_CLEAR;
  241. X     if ( DoIO(InSer)!=0) fprintf(stderr,"can't purge serport\n");
  242. X    }
  243. X}
  244. X
  245. X /*
  246. X  * Initialize timer device
  247. X  */
  248. X
  249. Xint SetTimer()
  250. X
  251. X{
  252. X    int err;
  253. X
  254. X    TimerPort =  CreatePort(0,0);
  255. X    if (TimerPort==NULL) return ERROR;
  256. X    IOTimeSigMask = 1 << (TimerPort->mp_SigBit);
  257. X    IOTime   = (struct timerequest *) CreateExtIO(TimerPort,sizeof(struct timerequest));
  258. X    if (IOTime==NULL) return ERROR;
  259. X    if( (err=OpenDevice(TIMERNAME,UNIT_VBLANK,IOTime,0))!=0)
  260. X     TimeOpen=0;
  261. X    else TimeOpen=1;
  262. X    return err;
  263. X}
  264. X
  265. X /*
  266. X  * Close timer device
  267. X  */
  268. X
  269. Xvoid CloseTimer()
  270. X{
  271. X    if( TimeOpen ) {
  272. X    CloseDevice(IOTime);
  273. X    TimeOpen=0;
  274. X    }
  275. X    if(IOTime) {
  276. X    DeleteExtIO(IOTime,sizeof(struct timerequest));
  277. X    IOTime=NULL;
  278. X    }
  279. X    if(TimerPort) {
  280. X    DeletePort(TimerPort);
  281. X    TimerPort=NULL;
  282. X    }
  283. X}
  284. X
  285. X/* send a break to the host */
  286. X
  287. Xvoid SendBreak()
  288. X{
  289. X    if ( SerOpen ) {
  290. X    InSer->IOSer.io_Command = SDCMD_BREAK;
  291. X    if( DoIO(InSer)!=0) fprintf(stderr,"SendBreak:error sending break\n");
  292. X    }
  293. X}
  294. X
  295. X /*
  296. X  * Read a character from serial port. Timeout is in tenths of seconds.
  297. X  *
  298. X  */
  299. Xint ReadSer(timeout)
  300. Xint timeout;
  301. X{
  302. X    int ch;
  303. X    ULONG mask,IntuiMask;
  304. X    static UBYTE *NextChar;
  305. X    int Quit;
  306. X
  307. X  /*  if(CheckQuit()) bibi(1);*/
  308. X    if( !SerOpen) return ERROR;
  309. X    if( Lleft>0 ) {
  310. X    --Lleft;
  311. X    return (*NextChar++);
  312. X     }
  313. X    IOTime->tr_time.tv_secs = timeout/10;
  314. X    IOTime->tr_time.tv_micro = 100000*(timeout%10);
  315. X    IOTime->tr_node.io_Command = TR_ADDREQUEST;
  316. X    SendIO(IOTime);
  317. X    SendSer(1,RecSerBuf);
  318. X    IntuiMask = 1 << (Win->UserPort->mp_SigBit);
  319. X    mask=Wait( InSerSigMask | IOTimeSigMask | IntuiMask);
  320. X    if (CheckQuit()) {
  321. X    KillIO(IOTime,mask);
  322. X    KillIO( (struct IOStdReq *)InSer,mask);
  323. X    bibi(1);
  324. X    }
  325. X    else if ((mask&InSerSigMask)!=0) {
  326. X        KillIO(IOTime,mask);
  327. X        GetMsg(InSerPort);
  328. X        ch=RecSerBuf[0];
  329. X        if( (Lleft=CharsWaiting())>0){/* find out how many characters are
  330. X                         waiting */
  331. X        InSer->IOSer.io_Data = (APTR)RecSerBuf;
  332. X        InSer->IOSer.io_Length = Lleft<SERBUFSIZE?Lleft:SERBUFSIZE;
  333. X        InSer->IOSer.io_Command = CMD_READ;
  334. X        DoIO(InSer);
  335. X        NextChar=RecSerBuf;
  336. X         }
  337. X        return(ch);
  338. X    }
  339. X    else  { /* it was the timer signal */
  340. X        KillIO( (struct IOStdReq *)InSer,mask);
  341. X        WaitIO(IOTime);
  342. X        return TIMEOUT;
  343. X    }
  344. X}
  345. X
  346. X /*
  347. X  * Determine the number of characters waiting in the serial.device
  348. X  * input buffer
  349. X  *
  350. X  */
  351. X
  352. XCharsWaiting()
  353. X{
  354. X    if( SerOpen ) {
  355. X        InSer->IOSer.io_Command = SDCMD_QUERY;
  356. X        if( DoIO(InSer)!=0) fprintf(stderr,"CharsWaiting: IO error\n");
  357. X        return (int)(InSer->IOSer.io_Actual);
  358. X    }
  359. X}
  360. X
  361. X /*
  362. X  * If IO isn't done Abort it
  363. X  * in any case GetMsg it
  364. X  *
  365. X  */
  366. X
  367. XKillIO(Req,Mask)
  368. Xstruct IOStdReq *Req;
  369. XULONG Mask;
  370. X{
  371. X  ULONG SigMask;
  372. X  struct MsgPort  *SigPort;
  373. X
  374. X    SigPort=Req->io_Message.mn_ReplyPort;
  375. X    SigMask=1 << (SigPort->mp_SigBit);
  376. X    if( (Mask & SigMask)==0 ) {
  377. X        AbortIO(Req);
  378. X        Wait(SigMask);
  379. X    }
  380. X    GetMsg(SigPort);
  381. X}
  382. SHAR_EOF
  383. echo "extracting Zmodem/term.c"
  384. sed 's/^X//' << \SHAR_EOF > Zmodem/term.c
  385. X#include "exec/types.h"
  386. X#include "exec/ports.h"
  387. X#include "exec/devices.h"
  388. X#include "exec/io.h"
  389. X#include "exec/memory.h"
  390. X#include "devices/console.h"
  391. X#include "intuition/intuition.h"
  392. Xstruct MsgPort *CreatePort();
  393. Xstruct IOStdReq *CreateStdIO();
  394. Xstruct Window *OpenWindow();
  395. Xvoid *GetMsg();
  396. X
  397. X#define ESC 27
  398. X
  399. X
  400. Xextern struct IOStdReq *ConWriteReq;
  401. Xextern struct IOStdReq *ConReadReq;
  402. Xextern struct Window *Win;
  403. Xextern ULONG InSerSigMask;
  404. Xextern int FullDuplex;
  405. Xextern struct MsgPort  *InSerPort;
  406. Xextern struct IOExtSer *InSer;
  407. Xstatic int ConOpen;
  408. Xextern struct MsgPort  *ConReadPort,*ConWritePort;
  409. X
  410. X/*
  411. X * mini-terminal function
  412. X * exit when user hits close box
  413. X *
  414. X */
  415. Xterm()
  416. X{
  417. X    char ConChar,SerChar;
  418. X    ULONG ConInMask,mask,IntuiMask;
  419. X    struct IntuiMessage *message;
  420. X
  421. X    ConInMask = 1 << (ConReadPort->mp_SigBit);
  422. X    IntuiMask = 1 << (Win->UserPort->mp_SigBit);
  423. X    QueueRead(ConReadReq,&ConChar);
  424. X    SendSer(1,&SerChar);
  425. X    while(1) {
  426. X    mask=Wait(ConInMask|InSerSigMask|IntuiMask);
  427. X    if(CheckQuit()) break;
  428. X    if( mask & ConInMask ) {
  429. X        GetMsg(ConReadPort);
  430. X        LWriteSer(&ConChar,1);
  431. X        if(!FullDuplex) ConPutChar(ConWriteReq,ConChar);
  432. X        QueueRead(ConReadReq,&ConChar);
  433. X    }
  434. X    if( mask & InSerSigMask ) {
  435. X        GetMsg(InSerPort);
  436. X        ConPutChar(ConWriteReq,SerChar&0x7F);
  437. X        SendSer(1,&SerChar);
  438. X    }
  439. X    }
  440. X    /*if( (mask & InSerSigMask)==0) {
  441. X    AbortIO(InSer);
  442. X    Wait(InSerSigMask);
  443. X    }
  444. X    GetMsg(InSerPort);
  445. X    if( (mask & ConInMask)==0) {
  446. X    AbortIO(ConReadReq);
  447. X    Wait(ConInMask);
  448. X    }
  449. X    GetMsg(ConReadPort);*/
  450. X    KillIO( (struct IOStdReq *)InSer,mask);
  451. X    KillIO(ConReadReq,mask);
  452. X    return 0;
  453. X}
  454. X
  455. X
  456. X/*
  457. X * Open a console device
  458. X *
  459. X */
  460. X      int
  461. XOpenConsole(WriteReq,ReadReq,Win)
  462. X    struct IOStdReq **WriteReq;
  463. X    struct IOStdReq **ReadReq;
  464. X    struct Window *Win;
  465. X{
  466. X    int error;
  467. X
  468. X    ConWritePort = CreatePort(0L,0L);
  469. X    if ( ConWritePort == NULL ) {
  470. X    CloseConsole();
  471. X    return -1;
  472. X    }
  473. X    *WriteReq = CreateStdIO(ConWritePort);
  474. X    if( WriteReq == NULL ) {
  475. X    CloseConsole();
  476. X    return -1;
  477. X    }
  478. X
  479. X    ConReadPort = CreatePort(0L,0L);
  480. X    if ( ConReadPort == NULL ) {
  481. X    CloseConsole();
  482. X    return -1;
  483. X    }
  484. X
  485. X    *ReadReq = CreateStdIO(ConReadPort);
  486. X    if( ReadReq == NULL ) {
  487. X    CloseConsole();
  488. X    return -1;
  489. X    }
  490. X
  491. X    (*WriteReq)->io_Data = (APTR) Win;
  492. X    (*WriteReq)->io_Length = sizeof(*Win);
  493. X    error = OpenDevice("console.device", 0, *WriteReq, 0);
  494. X    (*ReadReq)->io_Device = (*WriteReq)->io_Device;
  495. X    (*ReadReq)->io_Unit   = (*WriteReq)->io_Unit;
  496. X      /* clone required parts of the request */
  497. X    if( !error ) ConOpen=TRUE;
  498. X    else CloseConsole();
  499. X    return error;
  500. X}
  501. X
  502. XCloseConsole(ReadReq,WriteReq)
  503. Xstruct IOStdReq *WriteReq;
  504. Xstruct IOStdReq *ReadReq;
  505. X{
  506. X    if(ConOpen)       CloseDevice(ReadReq);
  507. X    if( ConReadPort)  DeletePort(ConReadPort);
  508. X    if( ReadReq)      DeleteStdIO(ReadReq);
  509. X    if( ConWritePort) DeletePort(ConWritePort);
  510. X    if( WriteReq)     DeleteStdIO(WriteReq);
  511. X}
  512. X
  513. X/* Output a single character to a specified console */
  514. X
  515. X      int
  516. XConPutChar(request,character)
  517. X      struct IOStdReq *request;
  518. X      char character;
  519. X      {
  520. X        request->io_Command = CMD_WRITE;
  521. X        request->io_Data = (APTR)&character;
  522. X        request->io_Length = 1;
  523. X        request->io_Flags = IOF_QUICK;
  524. X        DoIO(request);
  525. X        return(0);
  526. X      }
  527. X
  528. X/* Output a NULL-terminated string of characters to a console */
  529. X
  530. X      int
  531. XConPutStr(request,string)
  532. X      struct IOStdReq *request;
  533. X      char *string;
  534. X      {
  535. X        request->io_Command = CMD_WRITE;
  536. X        request->io_Data = (APTR)string;
  537. X        request->io_Length = -1;
  538. X        DoIO(request);
  539. X        return(0);
  540. X      }
  541. X
  542. X      /* queue up a read request to a console */
  543. X
  544. X      int
  545. XQueueRead(request,whereto)
  546. X      struct IOStdReq *request;
  547. X      char *whereto;
  548. X      {
  549. X        request->io_Command = CMD_READ;
  550. X        request->io_Data = (APTR)whereto;
  551. X        request->io_Length = 1;
  552. X        SendIO(request);
  553. X        return(0);
  554. X      }
  555. X
  556. X /*
  557. X  * Check if user has hit close box
  558. X  *
  559. X  */
  560. X
  561. Xint CheckQuit()
  562. X{
  563. X int Quit;
  564. X struct IntuiMessage *message;
  565. X
  566. X    Quit=FALSE;
  567. X    while( ((message = (struct IntuiMessage *)
  568. X            GetMsg(Win->UserPort) ) != NULL)) {
  569. X    if(message->Class==CLOSEWINDOW) Quit=TRUE;
  570. X    ReplyMsg(message);
  571. X    }
  572. X    return Quit;
  573. X}
  574. X
  575. XConGetC(request)
  576. Xstruct IOStdReq *request;
  577. X{
  578. X  char c;
  579. X
  580. X    request->io_Command = CMD_READ;
  581. X    request->io_Data = (APTR)&c;
  582. X    request->io_Length = 1;
  583. X    DoIO(request);
  584. X    return c;
  585. X}
  586. X
  587. SHAR_EOF
  588. echo "extracting expand.c"
  589. sed 's/^X//' << \SHAR_EOF > expand.c
  590. X/*************************************************************
  591. X * vt100 terminal emulator - Wild card and Directory support
  592. X *            :ts=8
  593. X *
  594. X *    v2.9 ACS - See change summary.
  595. X *    v2.7 870825 ACS - Use the *InfoMsg*() routines in window.c rather
  596. X *              than req().
  597. X *    v2.6 870227 DBW - bug fixes for all the stuff in v2.5
  598. X *    v2.5 870214 DBW - more additions (see readme file)
  599. X *    v2.4 861214 DBW - lots of fixes/additions (see readme file)
  600. X *    v2.3 861101 DBW - minor bug fixes
  601. X *    v2.2 861012 DBW - more of the same
  602. X *    v2.1 860915 DBW    - new features (see README)
  603. X *           860830 Steve Drew Added Wild card support,
  604. X *            features(expand.c)
  605. X *    v2.0 860809 DBW - Major rewrite
  606. X *    v1.1 860720 DBW    - Switches, 80 cols, colors, bug fixes
  607. X *    v1.0 860712 DBW    - First version released
  608. X *
  609. X *      Much of the code from this module extracted from
  610. X *      Matt Dillons Shell program. (Thanxs Matt.)
  611. X *************************************************************/
  612. X
  613. X#include "vt100.h"
  614. X
  615. Xstruct DPTR {                    /* Format of directory fetch ptr */
  616. X   struct FileLock *lock;        /* lock on directory   */
  617. X   struct FileInfoBlock *fib;    /* mod'd fib for entry */
  618. X};
  619. X
  620. X/*
  621. X * Disk directory routines
  622. X *
  623. X *
  624. X * diropen() returns a struct DPTR, or NULL if the given file does not
  625. X * exist.  stat will be set to 1 if the file is a directory.  If the
  626. X * name is "", then the current directory is openned.
  627. X *
  628. X * dirnext() returns 1 until there are no more entries.  The **name and
  629. X * *stat are set.  *stat = 1 if the file is a directory.
  630. X *
  631. X * dirclose() closes a directory channel.
  632. X *
  633. X */
  634. X
  635. Xstruct DPTR *
  636. Xdiropen(name, stat)
  637. Xchar *name;
  638. Xint *stat;
  639. X{
  640. X   struct DPTR *dp;
  641. X   int namelen, endslash = 0;
  642. X   struct FileLock *MyLock;
  643. X
  644. X   MyLock = (struct FileLock *)( (ULONG) ((struct Process *)
  645. X                 (FindTask(NULL)))->pr_CurrentDir);
  646. X   namelen = strlen(name);
  647. X   if (namelen && name[namelen - 1] == '/') {
  648. X      name[namelen - 1] = '\0';
  649. X      endslash = 1;
  650. X   }
  651. X   *stat = 0;
  652. X   dp = (struct DPTR *)malloc(sizeof(struct DPTR));
  653. X   if (*name == '\0')
  654. X      dp->lock = (struct FileLock *)DupLock (MyLock);
  655. X   else
  656. X      dp->lock = (struct FileLock *)Lock (name, ACCESS_READ);
  657. X   if (endslash)
  658. X      name[namelen - 1] = '/';
  659. X   if (dp->lock == NULL) {
  660. X      free (dp);
  661. X      return (NULL);
  662. X   }
  663. X   dp->fib = (struct FileInfoBlock *)
  664. X     AllocMem((long)sizeof(struct FileInfoBlock), MEMF_PUBLIC);
  665. X   if (!Examine (dp->lock, dp->fib)) {
  666. X      dirclose (dp);
  667. X      return (NULL);
  668. X   }
  669. X   if (dp->fib->fib_DirEntryType >= 0)
  670. X      *stat = 1;
  671. X   return (dp);
  672. X}
  673. X
  674. Xdirnext(dp, pname, stat)
  675. Xstruct DPTR *dp;
  676. Xchar **pname;
  677. Xint *stat;
  678. X{
  679. X   if (dp == NULL)
  680. X      return (0);
  681. X   if (ExNext (dp->lock, dp->fib)) {
  682. X      *stat = (dp->fib->fib_DirEntryType < 0) ? 0 : 1;
  683. X      *pname = dp->fib->fib_FileName;
  684. X      return (1);
  685. X   }
  686. X   return (0);
  687. X}
  688. X
  689. X
  690. Xdirclose(dp)
  691. Xstruct DPTR *dp;
  692. X{
  693. X   if (dp == NULL)
  694. X      return (1);
  695. X   if (dp->fib)
  696. X      FreeMem (dp->fib, (long)sizeof(*dp->fib));
  697. X   if (dp->lock)
  698. X      UnLock (dp->lock);
  699. X   free (dp);
  700. X   return (1);
  701. X}
  702. X
  703. Xvoid
  704. Xfree_expand(av)
  705. Xchar **av;
  706. X{
  707. X   char **base = av;
  708. X
  709. X   if (av) {
  710. X      while (*av) {
  711. X     free (*av);
  712. X     ++av;
  713. X      }
  714. X      free (base);
  715. X   }
  716. X}
  717. X
  718. X/*
  719. X * EXPAND(wild_name, pac)
  720. X *    wild_name      - char * (example: "df0:*.c")
  721. X *    pac            - int  *  will be set to # of arguments.
  722. X *
  723. X */
  724. X
  725. X
  726. Xchar **
  727. Xexpand(base, pac)
  728. Xchar *base;
  729. Xint *pac;
  730. X{
  731. X   char **eav = (char **)malloc (sizeof(char *));
  732. X   int  eleft, eac;
  733. X
  734. X   char *ptr, *name;
  735. X   char *bname, *ename, *tail;
  736. X   int stat, scr;
  737. X   struct DPTR *dp;
  738. X
  739. X   *pac = eleft = eac = 0;
  740. X   base = strcpy(malloc(strlen(base)+1), base);
  741. X   for (ptr = base; *ptr && *ptr != '?' && *ptr != '*'; ++ptr);
  742. X   for (; ptr >= base && !(*ptr == '/' || *ptr == ':'); --ptr);
  743. X   if (ptr < base) {
  744. X      bname = strcpy (malloc(1), "");
  745. X   } else {
  746. X      scr = ptr[1];
  747. X      ptr[1] = '\0';
  748. X      bname = strcpy (malloc(strlen(base)+1), base);
  749. X      ptr[1] = scr;
  750. X   }
  751. X   ename = ptr + 1;
  752. X   for (ptr = ename; *ptr && *ptr != '/'; ++ptr);
  753. X   scr = *ptr;
  754. X   *ptr = '\0';
  755. X   tail = (scr) ? ptr + 1 : NULL;
  756. X
  757. X   if ((dp = diropen (bname, &stat)) == NULL  ||  stat == 0) {
  758. X      free (bname);
  759. X      free (base);
  760. X      free (eav);
  761. X      InfoMsg1Line("Could not open directory");
  762. X      return (NULL);
  763. X   }
  764. X   while (dirnext (dp, &name, &stat)) {
  765. X      if (compare_ok(ename, name)) {
  766. X     if (tail) {
  767. X        int alt_ac;
  768. X        char *search, **alt_av, **scrav;
  769. X        struct FileLock *lock;
  770. X
  771. X        if (!stat)      /* expect more dirs, but this not a dir */
  772. X           continue;
  773. X        lock = (struct FileLock *)CurrentDir (dp->lock);
  774. X        search = malloc(strlen(name)+strlen(tail)+2);
  775. X        strcpy (search, name);
  776. X        strcat (search, "/");
  777. X        strcat (search, tail);
  778. X        scrav = alt_av = expand (search, &alt_ac);
  779. X        CurrentDir (lock);
  780. X        if (scrav) {
  781. X           while (*scrav) {
  782. X          if (eleft < 2) {
  783. X             char **scrav = (char **)
  784. X            malloc(sizeof(char *) * (eac + 10));
  785. X             movmem ((char *)eav, (char *)scrav, sizeof(char *) * (eac + 1));
  786. X             free (eav);
  787. X             eav = scrav;
  788. X             eleft = 10;
  789. X          }
  790. X          eav[eac] = malloc(strlen(bname)+strlen(*scrav)+1);
  791. X          strcpy(eav[eac], bname);
  792. X          strcat(eav[eac], *scrav);
  793. X          free (*scrav);
  794. X          ++scrav;
  795. X          --eleft, ++eac;
  796. X           }
  797. X           free (alt_av);
  798. X        }
  799. X     } else {
  800. X        if (eleft < 2) {
  801. X           char **scrav = (char **)
  802. X            malloc(sizeof(char *) * (eac + 10));
  803. X           movmem ((char *)eav, (char *)scrav, sizeof(char *) * (eac + 1));
  804. X           free (eav);
  805. X           eav = scrav;
  806. X           eleft = 10;
  807. X        }
  808. X        eav[eac] = malloc (strlen(bname)+strlen(name)+1);
  809. X        eav[eac] = strcpy(eav[eac], bname);
  810. X        strcat(eav[eac], name);
  811. X        --eleft, ++eac;
  812. X     }
  813. X      }
  814. X   }
  815. X   dirclose (dp);
  816. X   *pac = eac;
  817. X   eav[eac] = NULL;
  818. X   free (bname);
  819. X   free (base);
  820. X   if (eac)
  821. X      return (eav);
  822. X   free (eav);
  823. X   return (NULL);
  824. X}
  825. X
  826. X/*
  827. X * Compare a wild card name with a normal name
  828. X */
  829. X
  830. X#define MAXB   8
  831. X
  832. Xcompare_ok(wild, name)
  833. Xchar *wild, *name;
  834. X{
  835. X   char *w = wild;
  836. X   char *n = name;
  837. X   char *back[MAXB][2];
  838. X   int  bi = 0;
  839. X
  840. X   while (*n || *w) {
  841. X      switch (*w) {
  842. X      case '*':
  843. X     if (bi == MAXB) {
  844. X        InfoMsg1Line("Too many levels of '*'");
  845. X        return (0);
  846. X     }
  847. X     back[bi][0] = w;
  848. X     back[bi][1] = n;
  849. X     ++bi;
  850. X     ++w;
  851. X     continue;
  852. Xgoback:
  853. X     --bi;
  854. X     while (bi >= 0 && *back[bi][1] == '\0')
  855. X        --bi;
  856. X     if (bi < 0)
  857. X        return (0);
  858. X     w = back[bi][0] + 1;
  859. X     n = ++back[bi][1];
  860. X     ++bi;
  861. X     continue;
  862. X      case '?':
  863. X     if (!*n) {
  864. X        if (bi)
  865. X           goto goback;
  866. X        return (0);
  867. X     }
  868. X     break;
  869. X      default:
  870. X     if (toupper(*n) != toupper(*w)) {
  871. X        if (bi)
  872. X           goto goback;
  873. X        return (0);
  874. X     }
  875. X     break;
  876. X      }
  877. X      if (*n)  ++n;
  878. X      if (*w)  ++w;
  879. X   }
  880. X   return (1);
  881. X}
  882. X
  883. Xvoid
  884. Xset_dir(new)
  885. Xchar *new;
  886. X{
  887. X   register     char         *s;
  888. X   int               i;
  889. X   struct     FileLock     *lock;
  890. X   char             temp[60];
  891. X   struct       FileInfoBlock   *fib;
  892. X
  893. X   if (*new != '\000') {
  894. X      strcpy(temp, MyDir);
  895. X      s = new;
  896. X      if (*s == '/') {
  897. X     s++;
  898. X     for (i=strlen(MyDir);
  899. X          MyDir[i] != '/' && MyDir[i] != ':';
  900. X          i--);
  901. X     MyDir[i+1] = '\0';
  902. X     strcat(MyDir, s);
  903. X     }
  904. X      else if (exists(s, ':') == 0) {
  905. X     if (MyDir[strlen(MyDir)-1] != ':')
  906. X        strcat(MyDir, "/");
  907. X     strcat(MyDir, s);
  908. X     }
  909. X      else
  910. X     strcpy(MyDir, s);
  911. X
  912. X      if ((lock = (struct FileLock *)Lock(MyDir, (long)ACCESS_READ)) == 0) {
  913. X     InfoMsg2Line("Directory not found:",MyDir);
  914. X     strcpy(MyDir, temp);
  915. X     }
  916. X      else {
  917. X     fib = (struct FileInfoBlock *)AllocMem(
  918. X        (long)sizeof(struct FileInfoBlock), MEMF_PUBLIC);
  919. X     if (fib) {
  920. X        if (Examine(lock, fib)) {
  921. X        if (fib->fib_DirEntryType > 0) {
  922. X            UnLock(CurrentDir(lock));
  923. X            if (MyDir[strlen(MyDir)-1] == '/')
  924. X            MyDir[strlen(MyDir)-1] = '\000';
  925. X            }
  926. X        else {
  927. X            InfoMsg2Line("Not a Directory:",MyDir);
  928. X            strcpy(MyDir,temp);
  929. X            }
  930. X        }
  931. X        FreeMem(fib, (long)sizeof(struct FileInfoBlock));
  932. X        }
  933. X    else {
  934. X        InfoMsg1Line("Can't change directory...No free memory!");
  935. X        strcpy(MyDir,temp);
  936. X        }
  937. X    }
  938. X    }
  939. X}
  940. X
  941. Xexists(s,c)
  942. Xchar *s,c;
  943. X    {
  944. X    while (*s != '\000')
  945. X    if (*s++ == c) return(1);
  946. X    return(0);
  947. X    }
  948. SHAR_EOF
  949. echo "extracting init.c"
  950. sed 's/^X//' << \SHAR_EOF > init.c
  951. X/***************************************************************
  952. X * vt100 - terminal emulator - initialization
  953. X *                :ts=8
  954. X *
  955. X *    v2.9 ACS - Support new cmds EXT.  Use S and R for Send and Receive menu
  956. X *           items instead of ^ and V.  AREXX support.
  957. X *    v2.8a 880331 ACS - Allow lines 0 in init file to *really* mean
  958. X *              "use all available lines".
  959. X *    v2.7 870825 ACS - Allow execution of all script files specified on
  960. X *              command line (companion to changes in script.c).
  961. X *              Rolled menu init into one routine (do_menu_init()).
  962. X *    v2.6 870227 DBW - bug fixes for all the stuff in v2.5
  963. X *    v2.5 870214 DBW - more additions (see readme file)
  964. X *    v2.4 861214 DBW - lots of fixes/additions (see readme file)
  965. X *    v2.3 861101 DBW - minor bug fixes
  966. X *    v2.2 861012 DBW - more of the same
  967. X *    v2.1 860915 DBW - new features (see README)
  968. X *         860901 ACS - Added Parity and Word Length and support code
  969. X *         860823 DBW - Integrated and rewrote lots of code
  970. X *    v2.0 860809 DBW - Major rewrite
  971. X *    v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
  972. X *    v1.0 860712 DBW - First version released
  973. X *
  974. X ***************************************************************/
  975. X
  976. X#include "vt100.h"
  977. X
  978. Xstruct Device *ConsoleDevice = NULL;
  979. Xstruct IOStdReq ConReq;
  980. Xextern APTR OrigWindowPtr;
  981. Xextern int capture;        /* in vt100.c */
  982. X
  983. X/*   Used by script.c for script file chaining. */
  984. Xint script_files_todo = 0;
  985. Xchar **script_files = NULL;
  986. X
  987. Xchar line[256];
  988. X
  989. X/* Command key equivalences per menu.  Manipulated by script.c */
  990. X
  991. X/*   Equivalences for the File menu... */
  992. Xstruct filecmd {
  993. X    char mo;    /* Mode            */
  994. X    char se;    /* Send            */
  995. X    char re;    /* Receive        */
  996. X    char kg;    /* Kermit Get        */
  997. X    char kb;    /* Kermit Bye        */
  998. X    char ca;    /* Capture or Capturing */
  999. X    char nl;
  1000. X} filecmd_chars = { ' ', 'S', 'R', 'G', 'B', ' ', '\0' };
  1001. X
  1002. X/*   Equivalences for Mode sub-menu... */
  1003. Xstruct mode_cmd {
  1004. X    char as;    /* ascii mode        */
  1005. X    char xm;    /* xmodem mode        */
  1006. X    char xmc;    /* xmodemcrc mode    */
  1007. X    char ke;    /* kermit mode        */
  1008. X    char nl;
  1009. X} modecmd_chars = { ' ', 'X', ' ', 'K', '\0' };
  1010. X
  1011. X/*   Equivalences for the Comm menu... */
  1012. Xstruct commcmd {
  1013. X    char nl0;    /* Baud Sub-Item    */
  1014. X    char nl1;    /* Parity Sub-Item    */
  1015. X    char nl2;    /* Xfer mode Sub-Item    */
  1016. X    char sh;    /* Shared item        */
  1017. X    char nl;
  1018. X} commcmd_chars = { ' ', ' ', ' ', ' ', '\0' };
  1019. X
  1020. X/*   Equivalences for the Baud Rate sub-menu... */
  1021. Xstruct baudcmd {
  1022. X    char b03;    /* 0300            */
  1023. X    char b12;    /* 1200            */
  1024. X    char b24;    /* 2400            */
  1025. X    char b48;    /* 4800            */
  1026. X    char b96;    /* 9600            */
  1027. X    char bnl;
  1028. X} baudcmd_chars = { ' ', 'L', 'H', ' ', ' ', '\0' };
  1029. X
  1030. X/*   Equivalences for the Parity sub-menu... */
  1031. Xstruct parcmd {
  1032. X    char no;    /* NOne            */
  1033. X    char ma;    /* MArk            */
  1034. X    char sp;    /* SPace        */
  1035. X    char ev;    /* EVen            */
  1036. X    char od;    /* ODd            */
  1037. X    char nl;
  1038. X} parcmd_chars = { 'N', ' ', ' ', 'E', 'O', '\0' };
  1039. X
  1040. X/*   Equivalences for the Xfer Mode sub-menu... */
  1041. Xstruct modcmd {
  1042. X    char im;    /* IMage        */
  1043. X    char tx;    /* TeXt            */
  1044. X    char cn;    /* CoNvert        */
  1045. X    char ac;    /* AutoChop        */
  1046. X    char nl;
  1047. X} modcmd_chars = { 'I', 'T', ' ', ' ', '\0' };
  1048. X
  1049. X/*   Equivalences for the Script menu... */
  1050. Xstruct scrcmd {
  1051. X    char em;    /* Execute Macro    */
  1052. X    char ab;    /* Abort Macro        */
  1053. X    char rc;    /* AREXX Macro        */
  1054. X    char nl;
  1055. X} scrcmd_chars = { 'M', 'A', ' ', '\0' };
  1056. X
  1057. X/*   Equivalences for the Utility menu... */
  1058. Xstruct utilcmd {
  1059. X    char sb;    /* Send Break    */
  1060. X    char hu;    /* Hang Up    */
  1061. X    char cd;    /* Change Dir    */
  1062. X    char cs;    /* Clear Screen    */
  1063. X    char ec;    /* ECho        */
  1064. X    char wr;    /* WRap        */
  1065. X    char nk;    /* Num Key    */
  1066. X    char ac;    /* App Cur    */
  1067. X    char bs;    /* BS<->DEL    */
  1068. X    char xb;    /* Xfer beep    */
  1069. X    char mu;    /* Mouse up events    */
  1070. X    char md;    /* Mouse down events    */
  1071. X    char nl;
  1072. X} utilcmd_chars = { '.', ' ', 'D', ' ', ' ', 'W', 'K', 'C', ' ', ' ', ' ', ' ', '\0' };
  1073. X
  1074. Xstatic char *filetext[] = {
  1075. X    "Protocol",
  1076. X    "Send",
  1077. X    "Receive",
  1078. X    "Kermit Get",
  1079. X    "Kermit BYE",
  1080. X    "Capture"
  1081. X};
  1082. X
  1083. Xstatic char *modetext[] = {
  1084. X    "  Ascii",
  1085. X    "  Xmodem",
  1086. X    "  XmodemCRC",
  1087. X    "  Kermit"
  1088. X};
  1089. X
  1090. Xstatic char *commtext[] = {
  1091. X    "Baud Rate",
  1092. X    "Parity   ",
  1093. X    "Xfer Mode",
  1094. X    "  Shared ",
  1095. X};
  1096. X
  1097. Xstatic char *baudtext[] = {
  1098. X    "   300",
  1099. X    "  1200",
  1100. X    "  2400",
  1101. X    "  4800",
  1102. X    "  9600"
  1103. X};
  1104. X
  1105. Xstatic char *partext[] = {
  1106. X    "  None ",
  1107. X    "  Mark ",
  1108. X    "  Space",
  1109. X    "  Even ",
  1110. X    "  Odd  "
  1111. X};
  1112. X
  1113. Xstatic char *modtext[] = {
  1114. X    "  Image  ",
  1115. X    "  Text   ",
  1116. X    "  Convert",
  1117. X    "  AutoChop"
  1118. X};
  1119. X
  1120. Xstatic char *scrtext[] = {
  1121. X    "Execute Macro",
  1122. X    "Abort Execution",
  1123. X    "AREXX Macro"
  1124. X};
  1125. X
  1126. Xstatic char *utiltext[] = {
  1127. X    "Send Break",
  1128. X    "Hang Up",
  1129. X    "Change Dir",
  1130. X    "Clear Scrn",
  1131. X    "  Echo",
  1132. X    "  Wrap",
  1133. X    "  Num Key",
  1134. X    "  App Cur",
  1135. X    "  BS<->DEL",
  1136. X    "  Xfer Beep",
  1137. X    "  Mouse Up",
  1138. X    "  Mouse Dn",
  1139. X};
  1140. X
  1141. Xstruct HowToInit {
  1142. X    int LeftEdge;    /* in characters, NOT pixels    */
  1143. X    int Width;        /*     ditto            */
  1144. X    ULONG Flags;
  1145. X    char **text;
  1146. X    char *cmdkeys;
  1147. X};
  1148. X
  1149. Xstatic struct HowToInit menu_init[] = {
  1150. X    { 0, 20, ITEMTEXT | ITEMENABLED | HIGHCOMP,
  1151. X         filetext, (char *)(&filecmd_chars) },
  1152. X    {10, 17, ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  1153. X         modetext, (char *)(&modecmd_chars) },
  1154. X    { 0, 11, ITEMTEXT | ITEMENABLED | HIGHCOMP,
  1155. X         commtext, (char *)(&commcmd_chars) },
  1156. X    { 10, 12, ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  1157. X           baudtext, (char *)(&baudcmd_chars) },
  1158. X    { 10, 12, ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  1159. X          partext, (char *)(&parcmd_chars) },
  1160. X    { 10, 15, ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  1161. X          modtext, (char *)(&modcmd_chars) },
  1162. X    { 0, 20, ITEMTEXT | ITEMENABLED | HIGHCOMP,
  1163. X         scrtext, (char *)(&scrcmd_chars) },
  1164. X    { 0, 16, ITEMTEXT | ITEMENABLED | HIGHCOMP,
  1165. X         utiltext, (char *)(&utilcmd_chars) }
  1166. X};
  1167. X
  1168. X#define FILE_INIT_ENTRY    (&(menu_init[0]))
  1169. X#define MODE_INIT_ENTRY (&(menu_init[1]))
  1170. X#define COMM_INIT_ENTRY    (&(menu_init[2]))
  1171. X#define RS_INIT_ENTRY    (&(menu_init[3]))
  1172. X#define PAR_INIT_ENTRY    (&(menu_init[4]))
  1173. X#define XF_INIT_ENTRY    (&(menu_init[5]))
  1174. X#define SCRIPT_INIT_ENTRY    (&(menu_init[6]))
  1175. X#define UTIL_INIT_ENTRY    (&(menu_init[7]))
  1176. X
  1177. Xvoid do_menu_init();
  1178. X
  1179. X#if AREXX
  1180. Xchar *rexxerrmsgs[] = {
  1181. X    "",
  1182. X    "No AREXX library - AREXX unavailable.",
  1183. X    "Can't contact AREXX server - AREXX unavailable.",
  1184. X    "Can't create an AREXX msg - AREXX unavailable.",
  1185. X    "Can't get memory for hostname.",
  1186. X    "VT100 AREXX port already present - another VT100 up?",
  1187. X    "Can't get memory for AREXX port."
  1188. X};
  1189. X#endif /* AREXX */
  1190. X
  1191. Xchar *InitDefaults(argc,argv)
  1192. Xint    argc;
  1193. Xchar    **argv;
  1194. X    {
  1195. X    FILE    *fd = NULL;
  1196. X    char    *p = NULL, *ifile, temp[80];
  1197. X    int     i, l, dont_init = 0, customfudge, maxrows, maxlines;
  1198. X
  1199. X    for(l = 0; l < EXTMAX; l++)
  1200. X    ExtXfer[l] = NULL;
  1201. X
  1202. X    doing_init = 1;    /* make sure we only allow INIT script commands */
  1203. X    if (argc > 1) {
  1204. X    int start_of_script_files = 1;
  1205. X
  1206. X    if(strcmp(argv[1], "-i") == 0) {    /* No init file */
  1207. X        dont_init = 1;
  1208. X        start_of_script_files = 2;
  1209. X    }
  1210. X    else if(strcmp(argv[1], "+i") == 0) {    /* Use specified init file */
  1211. X        start_of_script_files = 3;
  1212. X            if((fd=fopen(argv[2],"r")) == NULL) {
  1213. X        ifile = AllocMem((LONG)(strlen(argv[2])+3), MEMF_PUBLIC|MEMF_CLEAR);
  1214. X        strcpy(ifile, "S:");
  1215. X        strcat(ifile, argv[2]);
  1216. X        fd = fopen(ifile, "r");
  1217. X        FreeMem(ifile, (LONG)(strlen(argv[2])+3));
  1218. X        ifile = NULL;
  1219. X        }
  1220. X    }
  1221. X    if(start_of_script_files > argc)
  1222. X        script_files_todo = 0;
  1223. X    else
  1224. X        script_files_todo = argc - start_of_script_files; /* # of cmdline script files left */
  1225. X    script_files = &(argv[start_of_script_files]);      /* Ptr to first of 'em */
  1226. X    }
  1227. X
  1228. X    if((p_font == NULL) || (p_font[0] == '\0'))
  1229. X    strcpy(myfontname, "topaz");
  1230. X    else
  1231. X    strcpy(myfontname, p_font);    /* Init font name */
  1232. X    strcat(myfontname, ".font");
  1233. X
  1234. X    if((p_device == NULL) || (p_device[0] == '\0'))
  1235. X    strcpy(mysername, SERIALNAME);
  1236. X    else
  1237. X    strcpy(mysername, p_device);
  1238. X
  1239. X#if AREXX
  1240. X    /*   Setup the AREXX interface now so user can use it during init. */
  1241. X    if( (RexxSysBase = (struct RxsLib *)OpenLibrary(RXSNAME, 0L))
  1242. X       == NULL)
  1243. X    puts("Can't open rexxsyslib.library - AREXX unavailable.");
  1244. X    else if( (i = makerexxport()) != 0)
  1245. X    cleanup(rexxerrmsgs[i], 256);
  1246. X#endif /* AREXX */
  1247. X
  1248. X    if(!dont_init)
  1249. X    if((fd == NULL) && ((fd=fopen("vt100.init","r")) == NULL))
  1250. X        fd=fopen("s:vt100.init","r");
  1251. X
  1252. X    if(fd != NULL) {
  1253. X    while (fgets(line,256,fd) != 0) {
  1254. X        if(line[strlen(line)-1] == '\n')
  1255. X        line[strlen(line)-1] = '\000';
  1256. X        p = next_wrd(&line[0],&l);
  1257. X        if (*p) {
  1258. X        *p |= ' ';
  1259. X        if (p[1]) p[1] |= ' ';
  1260. X        if (*p == '#') continue;
  1261. X        if (strncmp(p, "exi", 3) == 0) break;
  1262. X        exe_cmd(p,l);
  1263. X        }
  1264. X    }
  1265. X    fclose(fd);
  1266. X    }
  1267. X    doing_init = 0;
  1268. X
  1269. X    IntuitionBase = (struct IntuitionBase *)
  1270. X    OpenLibrary("intuition.library", INTUITION_REV);
  1271. X    if( IntuitionBase == NULL )
  1272. X    cleanup("can't open intuition",1);
  1273. X
  1274. X    GfxBase = (struct GfxBase *)
  1275. X    OpenLibrary("graphics.library",GRAPHICS_REV);
  1276. X    if( GfxBase == NULL )
  1277. X    cleanup("can't open graphics library",2);
  1278. X
  1279. X    DiskfontBase = (struct Library *)OpenLibrary("diskfont.library", 0L);
  1280. X    if(DiskfontBase == NULL)
  1281. X    cleanup("can't open diskfont library", 2);
  1282. X
  1283. X    if ( (myfont = (struct TextFont *)OpenFont(&myattr)) == NULL
  1284. X      && (myfont = (struct TextFont *)OpenDiskFont(&myattr)) == NULL) {
  1285. X    sprintf(temp, "Can't open font %s", myfontname);
  1286. X    cleanup(temp, 4);
  1287. X    }
  1288. X
  1289. X    Xsize = myfont->tf_XSize;
  1290. X    Ysize = myfont->tf_YSize;
  1291. X    BaseLine = myfont->tf_Baseline;
  1292. X
  1293. X    /* Now set up all the screen info as necessary */
  1294. X
  1295. X    maxrows = GfxBase->NormalDisplayRows;
  1296. X
  1297. X    /*   If user wants to use the current interlace setting then set p_interlace
  1298. X    ** according to what the ViewLord says it is. */
  1299. X    if(p_interlace == 2)
  1300. X    p_interlace = ((IntuitionBase->ViewLord.Modes & LACE) == LACE) ? 1 : 0;
  1301. X    else if((p_screen == 0) && ((IntuitionBase->ViewLord.Modes & LACE) == 0))
  1302. X    p_interlace = 0;
  1303. X
  1304. X    if(p_interlace)
  1305. X    maxrows *= 2;
  1306. X
  1307. X    customfudge = (p_screen == 1) ? 4 : 0;
  1308. X
  1309. X    /*   See if user wants to use everything available (specified LINES 0).If
  1310. X    ** so then set p_lines so we'll leave room for the window title.
  1311. X    ** (Ysize + 1) is the size of the window title bar.
  1312. X    ** (Ysize + 1 + customfudge) is used to allow us to account for the the 4
  1313. X    ** scan-lines we'll allow in CUSTOM screen mode so that the user can pull
  1314. X    ** the window down to expose the screen's depth arrangement gadgets.  Note
  1315. X    ** that it's OK to overwrite the last 2 lines or so of the window-title bar
  1316. X    ** (that's why we take the remainder first).
  1317. X    **/
  1318. X    if( ((maxrows - (Ysize + 1 - customfudge)) % Ysize) > (Ysize - 2) )
  1319. X    maxlines = (maxrows - Ysize + customfudge) / Ysize;
  1320. X    else
  1321. X    maxlines = (maxrows - (Ysize + 1 + customfudge)) / Ysize;
  1322. X    if(p_lines == 0)
  1323. X    p_lines = maxlines;
  1324. X    else if (p_lines > maxlines)
  1325. X    p_lines = maxlines;
  1326. X
  1327. X    /*   Set MINY.  MINY will be adjusted so we'll overwrite part of the
  1328. X    ** window title bar if necessary to get the last line to end at the bottom
  1329. X    ** of the window.
  1330. X    ** Remember that MINY is the location of the BASELINE of the character. */
  1331. X    {
  1332. X    int end = (Ysize + 2) + (p_lines * Ysize);
  1333. X
  1334. X    MINY = Ysize + 2;
  1335. X    if(end > maxrows)
  1336. X        MINY -= (end - maxrows);
  1337. X    MINY += BaseLine;
  1338. X    }
  1339. X    if(p_screen == 1 && p_interlace == 1)
  1340. X    NewScreen.ViewModes |= LACE;
  1341. X
  1342. X    MAXY = MINY + ((p_lines - 1) * Ysize);
  1343. X    top  = MINY; bot  = MAXY;
  1344. X    savx = MINX; savy = MINY;
  1345. X
  1346. X    NewWindow.Height = MAXY + customfudge + (Ysize - BaseLine);
  1347. X    NewWindow.MinHeight = NewWindow.Height;
  1348. X    NewWindow.MaxHeight = NewWindow.Height;
  1349. X    NewReqWindow.MaxHeight = NewWindow.Height;
  1350. X    NewWindow.TopEdge    = 0L;
  1351. X
  1352. X    if (p_screen == 1) {
  1353. X    if (p_depth > 2)
  1354. X        p_depth = 2;
  1355. X    else if (p_depth < 1)
  1356. X        p_depth = 1;
  1357. X    NewScreen.Depth = (long)p_depth;
  1358. X    NewScreen.Height = NewWindow.Height + customfudge;
  1359. X    NewScreen.TopEdge = 0;
  1360. X    } else {
  1361. X    p_depth    = 2L;
  1362. X    NewWindow.Screen = NULL;
  1363. X    NewReqWindow.Screen = NULL;
  1364. X    NewWindow.Type = WBENCHSCREEN;
  1365. X    NewReqWindow.Type = WBENCHSCREEN;
  1366. X    }
  1367. X
  1368. X    /* see if we exit with a startup script */
  1369. X    if (strncmp(p, "exi", 3) == 0) {
  1370. X    p = next_wrd(p+l+1,&l);
  1371. X    if (*p) return(p);
  1372. X    }
  1373. X    if (script_files_todo > 0) {
  1374. X        script_files_todo--;
  1375. X        return(*(script_files++));
  1376. X    }
  1377. X    return(NULL);
  1378. X    }
  1379. X
  1380. Xvoid InitDevs()
  1381. X{
  1382. XUSHORT    colors[4];
  1383. Xint    i;
  1384. XBYTE    *b,*c;
  1385. Xstruct Process *mproc;
  1386. X
  1387. X    if (p_screen == 1) {
  1388. X    if ((myscreen = (struct Screen *)OpenScreen(&NewScreen)) == NULL)
  1389. X        cleanup("can't open screen",3);
  1390. X    NewWindow.Screen = myscreen;
  1391. X    NewReqWindow.Screen = myscreen;
  1392. X    }
  1393. X
  1394. X    if ((mywindow = (struct Window *)OpenWindow(&NewWindow)) == NULL)
  1395. X    cleanup("can't open window",4);
  1396. X
  1397. X    if(OpenDevice("console.device", -1L, &ConReq, 0L))
  1398. X    cleanup("can't open console", 4);
  1399. X    ConsoleDevice = ConReq.io_Device;
  1400. X
  1401. X    if(p_screen == 1) {    /* Cause system reqs to come to this screen */
  1402. X    mproc = (struct Process *)FindTask(0L);
  1403. X    OrigWindowPtr = mproc->pr_WindowPtr;
  1404. X    mproc->pr_WindowPtr = (APTR)mywindow;
  1405. X    }
  1406. X
  1407. X    myviewport   = (struct ViewPort *)ViewPortAddress(mywindow);
  1408. X    myrastport   = (struct RastPort *)mywindow->RPort;
  1409. X
  1410. X    SetFont(myrastport,myfont);
  1411. X
  1412. X    if (p_depth > 1) myrequest.BackFill = 2;
  1413. X    if (p_screen != 0 && p_wbcolors == 0) {
  1414. X    colors[0] = p_background;
  1415. X    colors[1] = p_foreground;
  1416. X    colors[2] = p_bold;
  1417. X    colors[3] = p_cursor;
  1418. X    if (p_depth == 1)
  1419. X        LoadRGB4(myviewport, colors, 2L);
  1420. X    else
  1421. X        LoadRGB4(myviewport, colors, 4L);
  1422. X    }
  1423. X
  1424. X    Read_Request = (struct IOExtSer *)
  1425. X    AllocMem((long)sizeof(*Read_Request),MEMF_PUBLIC|MEMF_CLEAR);
  1426. X    Read_Request->io_SerFlags = (p_shared ? SERF_SHARED : 0);
  1427. X    Read_Request->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  1428. X    if(OpenDevice(mysername, (LONG)p_unit, (struct IORequest *)Read_Request, NULL))
  1429. X    cleanup("Can't open Read device",5);
  1430. X    rs_in = malloc(p_buffer+1);
  1431. X    Read_Request->io_SerFlags = 0L;
  1432. X    Read_Request->io_Baud      = p_baud;
  1433. X    Read_Request->io_ReadLen  = 8L;
  1434. X    Read_Request->io_WriteLen = 8L;
  1435. X    Read_Request->io_CtlChar  = 0x11130000L;
  1436. X    Read_Request->io_RBufLen  = p_buffer;
  1437. X    Read_Request->io_BrkTime  = p_break;
  1438. X    Read_Request->IOSer.io_Command = SDCMD_SETPARAMS;
  1439. X    DoIO((struct IORequest *)Read_Request);
  1440. X    Read_Request->IOSer.io_Command = CMD_READ;
  1441. X    Read_Request->IOSer.io_Length  = 1;
  1442. X    Read_Request->IOSer.io_Data    = (APTR) &rs_in[0];
  1443. X
  1444. X    Write_Request = (struct IOExtSer *)
  1445. X    AllocMem((long)sizeof(*Write_Request),MEMF_PUBLIC|MEMF_CLEAR);
  1446. X    b = (BYTE *)Read_Request;
  1447. X    c = (BYTE *)Write_Request;
  1448. X    for (i=0;i<sizeof(struct IOExtSer);i++)
  1449. X    *c++ = *b++;
  1450. X    Write_Request->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  1451. X    Write_Request->IOSer.io_Command = CMD_WRITE;
  1452. X    Write_Request->IOSer.io_Length = 1;
  1453. X    Write_Request->IOSer.io_Data = (APTR) &rs_out[0];
  1454. X
  1455. X    Timer_Port = CreatePort("Timer Port",0L);
  1456. X    Script_Timer_Port = CreatePort("Timer Port",0L);
  1457. X
  1458. X    if (OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest *)&Timer, NULL) ||
  1459. X    OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest *)&Script_Timer, NULL))
  1460. X    cleanup("can't open timer device",7);
  1461. X
  1462. X    Timer.tr_node.io_Message.mn_ReplyPort = Timer_Port;
  1463. X    Timer.tr_node.io_Command = TR_ADDREQUEST;
  1464. X    Timer.tr_node.io_Flags = 0;
  1465. X    Timer.tr_node.io_Error = 0;
  1466. X
  1467. X    Script_Timer.tr_node.io_Message.mn_ReplyPort = Script_Timer_Port;
  1468. X    Script_Timer.tr_node.io_Command = TR_ADDREQUEST;
  1469. X    Script_Timer.tr_node.io_Flags = 0;
  1470. X    Script_Timer.tr_node.io_Error = 0;
  1471. X
  1472. X    BeepWave = (UBYTE *)AllocMem(BEEPSIZE,(long)(MEMF_CHIP|MEMF_CLEAR));
  1473. X    if (BeepWave != 0)
  1474. X    BeepWave[0] = 100;
  1475. X
  1476. X    Audio_Port = CreatePort("Audio Port",0L);
  1477. X
  1478. X    Audio_Request.ioa_Request.io_Message.mn_ReplyPort = Audio_Port;
  1479. X    Audio_Request.ioa_Request.io_Message.mn_Node.ln_Pri = 85;
  1480. X    Audio_Request.ioa_Data = Audio_AllocMap;
  1481. X    Audio_Request.ioa_Length = (ULONG) sizeof(Audio_AllocMap);
  1482. X
  1483. X    if (OpenDevice(AUDIONAME, NULL, (struct IORequest *)&Audio_Request, NULL))
  1484. X    cleanup("can't open audio device",8);
  1485. X
  1486. X    Audio_Request.ioa_Request.io_Command = CMD_WRITE;
  1487. X    Audio_Request.ioa_Request.io_Flags = ADIOF_PERVOL;
  1488. X    Audio_Request.ioa_Data = BeepWave;
  1489. X    Audio_Request.ioa_Length = BEEPSIZE;
  1490. X    Audio_Request.ioa_Period = COLORCLOCK / (BEEPSIZE * BEEPFREQ);
  1491. X    Audio_Request.ioa_Volume = p_volume;
  1492. X    Audio_Request.ioa_Cycles = 100;
  1493. X}
  1494. X
  1495. X/*****************************************************************/
  1496. X/*    The following function initializes the structure arrays     */
  1497. X/*   needed to provide the File menu topic.             */
  1498. X/*****************************************************************/
  1499. Xvoid InitFileItems()
  1500. X{
  1501. X    int n, nxfer;
  1502. X    struct HowToInit Externs;    /* for the external xfer pgms */
  1503. X    char *p, *p1;
  1504. X
  1505. X    if(capture == TRUE)
  1506. X    filetext[FILEMAX-1] = "Capturing";
  1507. X    else
  1508. X    filetext[FILEMAX-1] = "Capture";
  1509. X    do_menu_init(FileItem, FileText, FILE_INIT_ENTRY, FILEMAX);
  1510. X    FileItem[0].SubItem = ModeItem;
  1511. X    do_menu_init(ModeItem, ModeText, MODE_INIT_ENTRY, MODEMAX);
  1512. X
  1513. X    p = (char *)&Externs; p1 = (char *)MODE_INIT_ENTRY;
  1514. X    for(n = 0; n < sizeof(struct HowToInit); n++)
  1515. X    *(p++) = *(p1++);
  1516. X
  1517. X    nxfer = MODEMAX;
  1518. X    for(n = 0; n < NumExts; n++) {
  1519. X    struct ExternalXfer *exp = ExtXfer[n];
  1520. X
  1521. X    nxfer = n + MODEMAX;
  1522. X    ModeItem[nxfer-1].NextItem = &ModeItem[nxfer];
  1523. X    Externs.text = &exp->dispname;
  1524. X    *Externs.cmdkeys = exp->cmdkey;
  1525. X    do_menu_init(&ModeItem[nxfer], &ModeText[nxfer], &Externs, 1);
  1526. X    ModeItem[nxfer].TopEdge = 10 * nxfer;
  1527. X    }
  1528. X
  1529. X    for(n = 0; n <= nxfer; n++ ) {
  1530. X    ModeItem[n].MutualExclude = (~(1 << n));
  1531. X    }
  1532. X    if(p_xproto > nxfer) {
  1533. X    p_xproto = MODEMAX - 1;
  1534. X    }
  1535. X    ModeItem[p_xproto].Flags |= CHECKED;
  1536. X}
  1537. X
  1538. X/******************************************************************
  1539. X**            Main Comm menu
  1540. X**        set up for Baud & Parity submenus
  1541. X*******************************************************************/
  1542. Xvoid InitCommItems()
  1543. X{
  1544. X    int n;
  1545. X
  1546. X    do_menu_init(CommItem, CommText, COMM_INIT_ENTRY, COMMAX);
  1547. X    CommItem[0].SubItem = RSItem;
  1548. X    CommItem[1].SubItem = ParItem;
  1549. X    CommItem[2].SubItem = XFItem;
  1550. X    CommItem[3].Flags |= CHECKIT | MENUTOGGLE;
  1551. X    if(p_shared)
  1552. X    CommItem[3].Flags |= CHECKED;
  1553. X    else
  1554. X    CommItem[3].Flags &= (-1L ^ CHECKED);
  1555. X
  1556. X/*****************************************************************/
  1557. X/*    The following initializes the structure arrays         */
  1558. X/*   needed to provide the BaudRate Submenu topic.         */
  1559. X/*****************************************************************/
  1560. X
  1561. X    do_menu_init(RSItem, RSText, RS_INIT_ENTRY, RSMAX);
  1562. X    for( n=0; n<RSMAX; n++ ) {
  1563. X    RSItem[n].MutualExclude = (~(1 << n));
  1564. X    }
  1565. X
  1566. X    /* select baud item chekced */
  1567. X    switch (p_baud) {
  1568. X    case 300:    n = 0; break;
  1569. X    case 1200:    n = 1; break;
  1570. X    case 2400:    n = 2; break;
  1571. X    case 4800:    n = 3; break;
  1572. X    case 9600:    n = 4; break;
  1573. X    default:    n = 2; p_baud = 2400;
  1574. X    }
  1575. X    RSItem[n].Flags |= CHECKED;
  1576. X
  1577. X/* initialize text for specific menu items */
  1578. X
  1579. X/*****************************************************************/
  1580. X/*    The following initializes the structure arrays         */
  1581. X/*   needed to provide the Parity   Submenu topic.         */
  1582. X/*****************************************************************/
  1583. X
  1584. X    do_menu_init(ParItem, ParText, PAR_INIT_ENTRY, PARMAX);
  1585. X    for( n=0; n<PARMAX; n++ ) {
  1586. X    ParItem[n].MutualExclude = (~(1 << n));
  1587. X    }
  1588. X
  1589. X    /* select parity item chekced */
  1590. X    ParItem[p_parity].Flags |= CHECKED;
  1591. X
  1592. X/*****************************************************************/
  1593. X/*    The following initializes the structure arrays         */
  1594. X/* initialize text for specific menu items */
  1595. X/*    needed to provide the Transfer Mode menu topic.         */
  1596. X/*****************************************************************/
  1597. X
  1598. X    do_menu_init(XFItem, XFText, XF_INIT_ENTRY, XFMAX);
  1599. X    
  1600. X    /* initialize each menu item and IntuiText with loop */
  1601. X    for(n = 0; n < 2; n++)
  1602. X    XFItem[n].MutualExclude = 2 - n;
  1603. X
  1604. X    /* mode checked */
  1605. X    XFItem[p_mode].Flags |= CHECKED;
  1606. X    if (p_convert)
  1607. X    XFItem[2].Flags |= CHECKED;
  1608. X
  1609. X    if (p_autochop)
  1610. X    XFItem[3].Flags |= CHECKED;
  1611. X    
  1612. X} /* end of InitCommItems() */
  1613. X
  1614. X
  1615. X/*****************************************************************/
  1616. X/*    The following function initializes the structure arrays     */
  1617. X/*   needed to provide the Script menu topic.             */
  1618. X/*****************************************************************/
  1619. Xvoid InitScriptItems()
  1620. X{
  1621. X    do_menu_init(ScriptItem, ScriptText, SCRIPT_INIT_ENTRY, SCRIPTMAX);
  1622. X}
  1623. X
  1624. X/*****************************************************************/
  1625. X/*    The following function initializes the structure arrays     */
  1626. X/*   needed to provide the Util menu topic.               */
  1627. X/*****************************************************************/
  1628. Xvoid InitUtilItems()
  1629. X{
  1630. X    int    n;
  1631. X
  1632. X    do_menu_init(UtilItem, UtilText, UTIL_INIT_ENTRY, UTILMAX);
  1633. X    /* initialize each menu item and IntuiText with loop */
  1634. X    for( n=0; n<UTILMAX; n++ ) {
  1635. X    if (n > 3)
  1636. X        UtilItem[n].Flags |= CHECKIT | MENUTOGGLE;
  1637. X    }
  1638. X
  1639. X    if (p_echo)
  1640. X    UtilItem[4].Flags |= CHECKED;
  1641. X    if (p_wrap)
  1642. X    UtilItem[5].Flags |= CHECKED;
  1643. X    if (p_keyapp == 0)
  1644. X    UtilItem[6].Flags |= CHECKED;
  1645. X    if (p_curapp)
  1646. X    UtilItem[7].Flags |= CHECKED;
  1647. X    if (p_bs_del)
  1648. X    UtilItem[8].Flags |= CHECKED;
  1649. X    if (p_xbeep)
  1650. X    UtilItem[9].Flags |= CHECKED;
  1651. X    if(p_mouse_up)
  1652. X    UtilItem[10].Flags |= CHECKED;
  1653. X    if(p_mouse_down)
  1654. X    UtilItem[11].Flags |= CHECKED;
  1655. X
  1656. X    swap_bs_del();    /* Setup keys[] properly... */
  1657. X    swap_bs_del();    /* ...for mode            */
  1658. X}
  1659. X
  1660. X/****************************************************************/
  1661. X/*   The following function inits the Menu structure array with */
  1662. X/*  appropriate values for our simple menu.  Review the manual    */
  1663. X/*  if you need to know what each value means.            */
  1664. X/****************************************************************/
  1665. Xvoid InitMenu()
  1666. X{
  1667. X    menu[0].NextMenu = &menu[1];
  1668. X    menu[0].LeftEdge = 5;
  1669. X    menu[0].TopEdge = 0;
  1670. X    menu[0].Width = 40;
  1671. X    menu[0].Height = 10;
  1672. X    menu[0].Flags = MENUENABLED;
  1673. X    menu[0].MenuName = "File";      /* text for menu-bar display */
  1674. X    menu[0].FirstItem = &FileItem[0]; /* pointer to first item in list */
  1675. X
  1676. X    menu[1].NextMenu = &menu[2];
  1677. X    menu[1].LeftEdge = 55;
  1678. X    menu[1].TopEdge = 0;
  1679. X    menu[1].Width = 88;
  1680. X    menu[1].Height = 10;
  1681. X    menu[1].Flags = MENUENABLED;
  1682. X    menu[1].MenuName = "Comm Setup";    /* text for menu-bar display */
  1683. X    menu[1].FirstItem = &CommItem[0];    /* pointer to first item in list */
  1684. X
  1685. X    menu[2].NextMenu = &menu[3];
  1686. X    menu[2].LeftEdge = 153;
  1687. X    menu[2].TopEdge = 0;
  1688. X    menu[2].Width = 56;
  1689. X    menu[2].Height = 10;
  1690. X    menu[2].Flags = MENUENABLED;
  1691. X    menu[2].MenuName = "Script";    /* text for menu-bar display */
  1692. X    menu[2].FirstItem = &ScriptItem[0];    /* pointer to first item in list*/
  1693. X
  1694. X    menu[3].NextMenu = NULL;
  1695. X    menu[3].LeftEdge = 225;
  1696. X    menu[3].TopEdge = 0;
  1697. X    menu[3].Width = 64;
  1698. X    menu[3].Height = 10;
  1699. X    menu[3].Flags = MENUENABLED;
  1700. X    menu[3].MenuName = "Utility";       /* text for menu-bar display */
  1701. X    menu[3].FirstItem = &UtilItem[0];  /* pointer to first item in list*/
  1702. X}
  1703. X
  1704. Xvoid do_menu_init(menuitem, menutext, initentry, max)
  1705. Xstruct MenuItem menuitem[];
  1706. Xstruct IntuiText menutext[];
  1707. Xstruct HowToInit *initentry;
  1708. Xint max;
  1709. X{
  1710. X    int n, nplus1;
  1711. X    char **temp;
  1712. X
  1713. X    /* initialize each menu item and IntuiText with loop */
  1714. X    for( n=0; n < max; n++ ) {
  1715. X    nplus1 = n + 1;
  1716. X    temp = initentry->text;
  1717. X    menutext[n].IText = (UBYTE *)temp[n];
  1718. X    menuitem[n].NextItem = &menuitem[nplus1];
  1719. X    menuitem[n].LeftEdge = initentry->LeftEdge * Ysize;
  1720. X    menuitem[n].TopEdge = 10 * n;
  1721. X    menuitem[n].Width = initentry->Width * Ysize;
  1722. X    menuitem[n].Height = 10;
  1723. X    menuitem[n].Flags = initentry->Flags;
  1724. X    menuitem[n].MutualExclude = 0;
  1725. X    menuitem[n].ItemFill = (APTR)&menutext[n];
  1726. X    menuitem[n].SelectFill = NULL;
  1727. X    if((initentry->cmdkeys != NULL)
  1728. X    && (initentry->cmdkeys[n])
  1729. X    && (initentry->cmdkeys[n] != ' ')) {
  1730. X        menuitem[n].Command  = initentry->cmdkeys[n];
  1731. X        menuitem[n].Flags   |= COMMSEQ;
  1732. X    }
  1733. X    else menuitem[n].Command = 0;
  1734. X    menuitem[n].SubItem = NULL;
  1735. X    menuitem[n].NextSelect = 0;
  1736. X    
  1737. X    menutext[n].FrontPen = 0;
  1738. X    menutext[n].BackPen = 1;
  1739. X    menutext[n].DrawMode = JAM2;/* render in fore and background */
  1740. X    menutext[n].LeftEdge = 0;
  1741. X    menutext[n].TopEdge = 1;
  1742. X    menutext[n].ITextFont = NULL;
  1743. X    menutext[n].NextText = NULL;
  1744. X    }
  1745. X    menuitem[max-1].NextItem = NULL;
  1746. X}
  1747. X
  1748. X#if AREXX
  1749. Xmakerexxport()
  1750. X{
  1751. X    int i,
  1752. X    ret = 0;
  1753. X    long hostlen = strlen(HOSTNAMEROOT) + strlen(mysername) + 1 + 2 + 1;
  1754. X            /* "VT100-"            name          "-" "xx" \0 */
  1755. X
  1756. X    if(HostName) {
  1757. X    FreeMem(HostName, (ULONG)(strlen(HostName)+1));
  1758. X    HostName = NULL;
  1759. X    }
  1760. X
  1761. X    if( (HostName = AllocMem(hostlen, MEMF_PUBLIC | MEMF_CLEAR)) == NULL)
  1762. X    return NOHOSTMEM;
  1763. X
  1764. X    sprintf(HostName, "%s%s-%02d", HOSTNAMEROOT, mysername, p_unit);
  1765. X
  1766. X    Forbid();
  1767. X    
  1768. X    if(FindPort(HostName) != NULL)
  1769. X    ret = HAVEVT100PORT;
  1770. X    else if( (FromRexxPort = (struct MsgPort *)AllocMem((LONG)sizeof(struct MsgPort),
  1771. X                 MEMF_PUBLIC | MEMF_CLEAR)) == NULL)
  1772. X    ret = NOPORTMEM;
  1773. X    else {
  1774. X    InitPort(FromRexxPort, HostName);
  1775. X    AddPort(FromRexxPort);
  1776. X    }
  1777. X
  1778. X    Permit();
  1779. X    if(ret && RexxSysBase) {
  1780. X    CloseLibrary((struct Library *)RexxSysBase);
  1781. X    RexxSysBase = NULL;
  1782. X    }
  1783. X    return ret;
  1784. X}
  1785. X#endif /* AREXX */
  1786. SHAR_EOF
  1787. echo "End of archive 5 (of 9)"
  1788. # if you want to concatenate archives, remove anything after this line
  1789. exit
  1790.